#include "bluetooth_task.h"

TaskHandle_t blueHandler;

	
//用来去书写 心跳任务需要外设进行初始化	
void init_bluetooth(){
    //初始化usart3
    usart3_init(9600);

}

void bluetooth_task(void * param){
	
	char data[200];
	while (1) {
        	
			printf("123456789\r\n");
			 //从HC - 05接收数据
			memset(data, 0, 200);
			int index = 0;
			while (1) {
					while (USART_GetFlagStatus(USART3, USART_FLAG_RXNE) == RESET);
				  char res = USART_ReceiveData(USART3);
					if(res=='\0') continue;  //一直读空的情况不要
					if(res=='\n'){//已经结束
							data[index] = '\0';
						  break;
					}else{
							data[index] = res;
					}
					index++;
			}

			printf("%s.......\r\n",data);
			
			

	}

	
}

void createBluetoothTask(){
    xTaskCreate(
        bluetooth_task,
        "bluetooth_task",
        128,
        NULL,
        2,
        &blueHandler
    );
}
